package com.baichen.agent.controller;

import com.baichen.agent.CustomerServiceAgent;
import com.baichen.agent.model.ChatForm;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "Agent Controller", description = "APIs for interacting with the Customer Service Agent")
@RestController
@RequestMapping("/agent")
public class AgentController {
    @Autowired
    private CustomerServiceAgent customerServiceAgent;

    @Operation(summary = "Chat with the Customer Service Agent")
    @RequestMapping("/chat")
    public String chat(@RequestBody ChatForm form) {
        return customerServiceAgent.chat(form.getMemoryId(), form.getMessage());
    }

    @Operation(summary = "Chat with the Customer Service Agent")
    @RequestMapping(value = "/stream/chat", produces = "text/stream;charset=utf-8")
    public String streamChat(@RequestBody ChatForm form) {
        return customerServiceAgent.chat(form.getMemoryId(), form.getMessage());
    }
}
